<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>后台评论</title>
<link rel="stylesheet" href="css/review.css">
</head>
<body>
	<div id="review">
		<table border="1" width="1200px">
			<tr>
				<td>评论Id</td>
				<td>商品Id</td>
				<td>rContent</td>
				<td>用户Id</td>
				<td>评论时间</td>
			</tr>
		</table>
	</div>
</body>
<script src="js/jquery.min.js"></script>
<script>
load();
function load(){
	 	var keyword = " ";
	 	$.ajax({
	 		url:"/shopping/getReview.do",
	 		type:"GET",
	 		data:{
				"pageNum":1,
	 			"pageSize":10,
	 			"keyword":keyword
	 		},
	 		success:function(data){
	 			console.log(data);
	 			var r = data.data;
				for(var i = 0;i < r.length;i++){
	 				var g = r[i];
	 				var $tr = $("<tr></tr>")
	 				var $input1 = $("<input type='text' name='rId' class='rId'>").val(g.rId);
					var $input2 = $("<input type='text' name='goodsId' class='goodsId'>").val(g.goodsId);
					var $input3 = $("<input type='text' name='rContent' class='rContent'>").val(g.rContent);
	 				var $input4 = $("<input type='text' name='userId' class='userId'>").val(g.userId);
	 				var $input5 = $("<input type='text' name='rTime' class='rTime'>").val(g.rTime);
	 				var $input8 = $("<input type='button' value='删除'>").click(function(){
	 					$.ajax({
	 						url:"/shopping/updateReview.do",
	 						type:"GET",
	 						data:{
	 							"rId":g.rId
	 							"keyword":"删除"
	 						},
	 						success:function(data){
	 							alert("删除成功");
	 						}
	 					});
	 				});
	 				var $input9 = $("<input type='button' value='修改'>").click(function(event){
	 					
	 					$input9.val("确认").click(function(){
	 						var rId = $(".rId").val();
	 						var goodsId = $(".goodsId").val();
	 						var rContent = $(".rContent").val();
	 						var userId = $(".userId").val();
	 						$.ajax({
	 							url:"/shopping/updataOrderGoods.do",
	 							type:"GET",
	 							data:{
	 								"rId":g.rId,
	 								"rContent":rContent,
	 								"userId":userId,
	 								"goodsId":goodsId
	 							},
	  							success:function(data){
	 							alert("更改成功");
	  							}	
	 						});
	 					});
	 				});
	 				
	 			
	 			$($tr).append($input1).append($input2).append($input3).append($input4).append($input5).append($input8).append($input9);
	 			$("table").append($tr);
	 			}
	 		}
	 	})
	 	$("input").css({
	 		width:"80px"
	 	})
	 }
</script>
</html>